<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="/WEB-INF/tlds/c.tld"%>
<%@ taglib prefix="spring" uri="/WEB-INF/tlds/spring.tld"%>
<c:set var="BasePath" value="${pageContext.request.contextPath}"></c:set>
<c:set var="Plugins" value="${pageContext.request.contextPath}/res/plugins"></c:set>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>系统参数配置列表</title>

<link href="${Plugins}/ligerUI/skins/Aqua/css/ligerui-all.css" rel="stylesheet" type="text/css" />
<link href="${Plugins}/ligerUI/skins/ligerui-icons.css" rel="stylesheet" type="text/css" />
<script src="${Plugins}/jquery/jquery-1.3.2.min.js"	type="text/javascript"></script>
<script src="${Plugins}/ligerUI/js/ligerui.min.js" type="text/javascript"></script>
<script type="text/javascript" src="${BasePath}/res/js/ligerCommon.js"></script>
<script src="${Plugins}/datepicker/WdatePicker.js" type="text/javascript"></script> 
<style type="text/css">
#searchbar{
   margin-bottom: 10px;
   margin-left:15px;
  }
  .navbar {
		height: 20px;
		border-bottom: #E6E6E6 solid 1px;
		line-height: 20px;
	}
.l-button-search {
	width: 50px;
	margin-left: 10px;
	padding-bottom: 2px;
	display: inline;
}
</style>
</head>

<body style="padding:6px; overflow:hidden;">
<div class="navbar">
		<span>您当前的位置：</span>
		系统管理 &gt; 系统参数配置列表
</div>
<br />
<form action="#" name="queryForm" id="queryForm" method="POST" >
<div id="searchbar"><br>
参数名称：<input type="text" id="paramName" name="paramName" value="${paramterVo.paramName}" />&nbsp;&nbsp;
<%-- 商品名称：<input type="text" id="productName" name="productName" value="${defective.productName}" />&nbsp;&nbsp;
仓库名称：<input type="text" id="warehouse" name="warehouse" value="${defective.warehouse}" />&nbsp;&nbsp;
处理状态： <select id="storageMethods" name="storageMethods">
         		<option value="-1">请选择</option>
         		<option value="0" ${defective.storageMethods == 0 ? "selected='selected'" : ""}>待出库</option>
         		<option value="1" ${defective.storageMethods == 1 ? "selected='selected'" : ""}>处理完成</option>
         	</select> &nbsp;&nbsp; --%>
         <input type="submit" id="btnSearch" value="查询" class="l-button-search" />
         <input type="button" id="btnReset" value="重置" class="l-button-search" />
</div>
</form>
<br />
<div id="maingrid" style="margin:0; padding:0"></div>
  <div style="display:none;">
  <!-- 展示列表数据  -->
</div>

	<script>
    var basePath='${BasePath}';
    var grid = null;
	
    $(function () {
    	 // 重置
        $("#btnReset").click(function(){
    		$('#searchbar :input').not(':submit, :button, :reset').val('').removeAttr('checked').removeAttr('selected');
    	});
    	
       /*  $("#id").show()表示display:block, 
        $("#id").hide()表示display:none;  */
        grid = $("#maingrid").ligerGrid({
            columns: [
          /*   { display: 'ID', name: 'id'}, */
            { display: '参数名称', name: 'paramName'},
            { display: '参数键', name: 'paramKey'},
            { display: '参数值', name: 'paramValue'},
            { display: '描述', name:'memo'},
            { display: '创建人', name: 'paramUser'},
            { display: '创建时间', name: 'createTime'},
            { display: '是否可用', name: 'isAvailable' ,render:function(rowdata,rowindex,value){
	            var text = null;
	            switch(value){
		            case 0: text="不可用"; break;
		            case 1: text="可用"; break;  
	            default : break; 
            }
            return text;
       	 	}},
            { display: '是否多值', name: 'isMultipleValues',render:function(rowdata,rowindex,value){
	            var text = null;
	            switch(value){
		            case 0: text="单个值"; break;
		            case 1: text="多个值"; break;  
	            default : break; 
            }
            return text;
       	 	}},
            { display: '操作人', name:'updater'},
            { display: '最新修改时间', name:'updateTime'},
            { display: '操作',width:'15%', isSort: false, render: function (rowdata, rowindex, value){
             	var  h = "<a href='javascript:updateDefective(" + rowindex + ")'>修改</a> ";
               	h += "<a href='javascript:deleteDefective(" + rowindex + ")'>删除</a> ";
                return h;
            	}
            }
            ], 
            pageSize:30,
            width: '100%',
            height: '100%',
            dataType: 'server', 
            dataAction: 'server',
            pagesizeParmName: 'pageSize',
            parms: [
					 {name: "paramName", value:$("#paramName").val()},
                    ],
			url: basePath+'/manager/system/parameter/ajaxToParamsList.do',
			toolbar: toolbar
        });
    });
    var toolbar = '';
    toolbar = {
    	items: [
    			{ text: "新增参数配置", click: addDefective, icon: "add" }
        		]
       		 };
    
    /**
     * 新增品牌信息
     */
    function addDefective(){
    		var url=basePath+'/manager/system/parameter/to_add_parameter.do';
        	url+="?pTabid="+WIN_TAB.getSelectedTabItemID();
        	window.parent.f_addTab('新增参数配置','新增参数配置',url);
    }
     
    /**
     * 修改次品信息
     */
    function updateDefective(rowindex){
    	var id=grid.getData()[rowindex].id;
          var url=basePath+'/manager/system/parameter/to_update_parameter.do?id='+id;
          url+="&pTabid="+WIN_TAB.getSelectedTabItemID();
    	  window.parent.f_addTab('修改参数配置','修改参数配置',url);
    }
    
    /**
     * 删除次品信息
     */
    function deleteDefective(rowindex) {
    	var id=grid.getData()[rowindex].id;
    	$.ligerDialog.confirm('确定删除',
    		function(yes) {if (yes) {
    			$.post(
    					basePath+ '/manager/system/parameter/deleteParamter.do',
    					{id : id},
    					function(data) {
    						if (data == 'success') {
    							window.parent.f_tip('删除成功');
    							window.location.reload();
    						} else if (data == 'fail') {
    							window.parent.f_tip('删除失败');
    						}else{
    							window.parent.f_tip(data);
    						};
    					}
    			);
    		};
    	});
    }
    
    var toolbar;
    var roles = new Array();
    '<c:forEach items="${roleVos}" var="item">';
    roles.push('${item.roleCode}');
    '</c:forEach>';
    
    var rpm = 0;
	if (roles.length > 0) {
		var ex = [];
		var add = [];
		var items = [];
		for(var i=0; i<roles.length; i++) {
			//商品专员,商品主管,管理员
       		if(roles[i] == 'GOOD_PERSON' || roles[i] == 'SYSTEM_ADMIN'){
    			add = [{ text: "新增参数配置",id:"add", click: addCommodity, icon: "add"},{ line: true }];
    		}
    		if (roles[i] == 'GOODS_SUPERVISOR' || roles[i] == 'FINANCIAL_PRINCIPAL'  || roles[i] == 'SYSTEM_ADMIN') {
    			ex = [{text: '导出EXCEL', click: doExportExcel, icon: "print"},{ line: true }];
    		}
    	}
		items = items.concat(ex);
		items = items.concat(add);
		toolbar = {items : items};
	}
   
    </script>
	
</body>
</html>